package org.syncsoft.overalt.gui.api;

import javax.swing.JOptionPane;

import org.syncsoft.overalt.common.api.Resource;
import org.syncsoft.overalt.gui.api.window.AbstractWindow;
import org.syncsoft.overalt.gui.api.window.AbstractWindowController;
import org.syncsoft.overalt.gui.impl.window.addFile.AddFileWindowController;
import org.syncsoft.overalt.gui.impl.window.commit.CommitWindowController;
import org.syncsoft.overalt.gui.impl.window.shareFolder.ShareFolderWindowControll;
import org.syncsoft.overalt.gui.impl.window.viewHistory.ViewHistoryWindowController;

public class GuiWindowControll {
	public static void execute(String queryString) {
		String parameters[] = queryString.split("#");
		
		if (parameters.length >= 2) {
			int command = Integer.parseInt(parameters[0].trim());
			String path = parameters[1].trim();
			
			AbstractWindowController<? extends AbstractWindow> windowController = null;
			
			switch(command) {
				case 1:
					windowController = new ShareFolderWindowControll(path);
					break;
				case 2:
					break;
				case 3:
//					new CheckModification();
//					break;
				case 4:
					break;
				case 5:
					windowController = new CommitWindowController(path);
					break;
				case 6:
					break;
				case 7:
					windowController = new AddFileWindowController(path);
					break;
				case 8:
					windowController = new ViewHistoryWindowController(path);
					break;
				case 9:
//					new About();
					break;
				default:
					JOptionPane.showMessageDialog(null, Resource.getProperty("overalt.text.error.command.not.found"), "Error", JOptionPane.ERROR_MESSAGE);
			}
			
			if (windowController != null) {
				windowController.start();
			}
		}
	}
}
